﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PROJECT_BOMBER.BLL;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Graphics;
using PROJECT_BOMBER.BLL.Events;

namespace PROJECT_BOMBER.BLL
{
    public class MainMenuState : GameState
    {
        internal Texture2D img;
        internal MenuButton menuButton;
        internal MouseEvent mouseEvent;

        public override void Initialize()
        {
            img = Globals.Content.Load<Texture2D>("menu");
            menuButton = new MenuButton(new Vector2((Globals.GDM.PreferredBackBufferWidth - 300) / 2, Globals.GDM.PreferredBackBufferHeight / 2), Globals.Content.Load<Texture2D>("bouton"), Globals.Content.Load<Texture2D>("bouton"), new Microsoft.Xna.Framework.Rectangle());
            Globals.Game.IsMouseVisible = true;
            mouseEvent = new MouseEvent();

        }

        public override void Update(float deltatime)
        {
            if (mouseEvent.UpdateMouse() == true)
            {
                if (mouseEvent.getMouseContainer().Intersects(menuButton.getContainer()))
                {
                    Globals.Game.IsMouseVisible = false;
                    Globals.GameStateStack.Set(new LoadState(new PlayState()));

                }
            }

            KeyboardState ks = Keyboard.GetState();
            if (ks.IsKeyDown(Keys.S))
            {
                Globals.Game.IsMouseVisible = false;
                Globals.GameStateStack.Set(new LoadState(new PlayState()));
            }
        }

        public override void Draw()
        {

            Globals.SpriteBatch.Begin();

            Globals.SpriteBatch.Draw(img, new Vector2((Globals.GDM.PreferredBackBufferWidth - 972) / 2, (Globals.GDM.PreferredBackBufferHeight - 685) / 2), Color.White);

            menuButton.DrawButton(Globals.SpriteBatch);

            Globals.GDM.GraphicsDevice.Clear(Color.Black);
            Globals.SpriteBatch.End();
        }

        public override void Load()
        {
        }

        public override void Unload()
        {
            
        }
    }
}
